package com.spit.amoeba.base

import androidx.databinding.ObservableField
import androidx.lifecycle.MutableLiveData
import com.spit.fammo.R
import com.spit.fammo.bean.AppRoomDataBase
import com.spit.fammo.util.CacheUtil
import me.hgj.jetpackmvvm.base.appContext
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.callback.databind.BooleanObservableField
import me.hgj.jetpackmvvm.callback.databind.StringObservableField

/**
 * User: Nike
 *  2024/11/7 16:47
 */
open class MyBaseViewModel : BaseViewModel() {

    var searchTextData: MutableLiveData<String> = MutableLiveData()

    var searchText = StringObservableField("")

    val userId = CacheUtil.getUser()?.userid

    val companyID = CacheUtil.getCompanyID()

    val assetDao = AppRoomDataBase.get().getAssetDao()

    val configDao = AppRoomDataBase.get().getConfigDao()

    val listingDao = AppRoomDataBase.get().getListingDao()

    val stockTakeListDao = AppRoomDataBase.get().getStockTakeListDao()

    val uploadOrderDao = AppRoomDataBase.get().getUploadOrderDao()

    val uploadOrderListDao = AppRoomDataBase.get().getUploadOrderListDao()

    var openState = StringObservableField()

    var title = StringObservableField()

    var name = StringObservableField()

    val isOpen = BooleanObservableField()

    var openStatus = object : ObservableField<String>(isOpen){
        override fun get(): String {
            return if(isOpen.get()){
                appContext.getString(R.string.stop)
            }else{
                appContext.getString(R.string.start)
            }
        }
    }

}